#include "SStructMember.h"


std::string SStructMember::GetTypeName()
{
	if ( Utility::IsSimpleType(type) )
	{
		return Utility::GetTypeName( type );
	}

	return typeDescriptor->GetName();
}

SStructMemberSp SStructMember::Create( string name, string description, SType type )
{
	if ( name.empty() )
	{
		throw SArgumentException("Name cannot be empty.");
	}
	if ( Utility::IsComplexType(type) )
	{
		throw SArgumentException("The type is complex so you must to provide the typeDescriptor.");
	}

	return SStructMemberSp(new SStructMember(name, description, type));
}

SStructMemberSp SStructMember::Create( string name, string description, TypeDescriptorSp typeDescriptor )
{
	if ( name.empty() )
	{
		throw SArgumentException("Name cannot be empty.");
	}
	if ( !typeDescriptor )
	{
		throw SArgumentException("You must to set the typeDescriptor.");
	}
	if ( !typeDescriptor->IsValid() )
	{
		throw SArgumentException("The typeDescriptor is invalid");
	}

	return SStructMemberSp(new SStructMember(name, description, typeDescriptor));
}